<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<jsp:directive.page import="java.util.Enumeration"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
	String registerError = (String)request.getSession().getAttribute("errorMsg");
	if (registerError == null){
		registerError = "";
	}

	Enumeration attrs = request.getSession().getAttributeNames();
 	while (attrs.hasMoreElements()){
 		request.getSession().removeAttribute((String)attrs.nextElement());
 	}
 	
%>
<html>

<style>
	button {
		width: 150px;
		height: 30px;
	}
	form {
		margin: 0;
	}
</style>
	<head>
		<title>用户注册</title>
		<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> 
		<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> 
		<META HTTP-EQUIV="Expires" CONTENT="0">
	</head>
	<body>
		<div style="margin: auto; margin-top: 200px; width: 400px; background-color: lightgreen; padding: 10px;">
			<div style="text-align:center; font-size: 24pt; font-weight: bold; margin-bottom: 10px;">课件分享系统</div>
			<div style="color: red"><%=registerError%></div>
			<form method="post" action="servlet/Register"> 
				<table style="width: 80%;margin:auto">
					<colgroup>
						<col width="30%">
						<col width="70%">
					</colgroup>
					<tr style="height:40px;"><td>用户名：</td>
					<td><input type="text" style="padding:2px;width:100%;border:1px solid darkgray;height:30px;" name="username"></td></tr>
					<tr style="height:40px;"><td>密码：</td>
					<td><input type="password" style="padding:2px;width:100%;border:1px solid darkgray;height:30px;" name="password"></td></tr>
					<tr style="height:40px;"><td>邮箱地址：</td>
					<td><input type="text" style="padding:2px;width:100%;border:1px solid darkgray;height:30px;" name="email"></td></tr>
					<tr style="height:40px;"><td>身份编号：</td>
					<td><input type="text" style="padding:2px;width:100%;border:1px solid darkgray;height:30px;" name="identityNo"></td></tr>
				</table>
			</form>
			<Button style="margin: 10px 120px 0;" onclick="doSubmit(document.forms[0]);">确认注册</Button>
		</div>
	</body>
	<script>
		function doSubmit(form){
			if (!form.username.value){
				alert("用户名不能为空！");
			}else if (!form.password.value){
				alert("密码不能为空！");
			}else if (!form.email.value){
				alert("邮箱不能为空！");
			}else if (!form.identityNo.value){
				alert("验证信息不能为空！");
			}else if (form.identityNo.value.indexOf("ST") != 0 && form.identityNo.value.indexOf("T") != 0 ){
				alert("验证编号必须以'ST'或'T'开头");
			}else{
				form.submit();
			}
		}
	</script>
</html>
